<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="images/favicon.png">
    <title>登录</title>
    <link rel="stylesheet" href="css/responsive.css">
    <link rel="stylesheet" href="element/theme-default/index.css">
    <link rel="stylesheet" href="css/login.css?v=20112">
    <script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/vue.js"></script>
    <script src="element/index.js"></script>
    <!--[if lt IE 9]>
    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="wrap">
        <div class="login_box">
            <div class="login_left">
                <div>
                    <img src="images/login_logo.png" alt="">
                </div>
                <p>车联网</p>
                <p>云服务平台</p>
            </div>
            <div class="login_right">
                <p class="login_title">登录</p>
                <div class="login_form" @keyup.enter="handleLogin">
                    <div class="user">
                        <span><img src="images/user_icon.png" alt=""></span>
                        <input type="text" placeholder="用户名" v-model="form.userName">
                    </div>
                    <div class="password">
                        <div class="password_box">
                            <span><img src="images/password_icon.png" alt=""></span>
                            <input placeholder="密码" v-model="form.userPassword" :type="passwordShow?'text':'password'">
                        </div>
                        <div class="isshowpass" @click="passwordShow=!passwordShow">
                            <img v-if="passwordShow" src="images/show_password.png" alt="">
                            <img v-else src="images/notshow_password.png" alt="">
                        </div>
                    </div>
                    <div class="login_btn"><el-button type="primary" @click="handleLogin">登录</el-button></div>
                </div>
            </div>
        </div>
    </div>
<script src="js/prototype.js?v=22231"></script>
<script>
    var myVue = new Vue({
        el: ".wrap",
        data: {
            passwordShow:false,      //密码是否显示
            form:{
                userName:"",       //用户名
                userPassword:""        //密码
            }
        },
        methods: {
            //点击提交按钮的方法
            handleLogin:function(){
                var _this=this;
                if(!_this.form.userName){
                    _this.$message.error('抱歉,请输入用户名!');
                    return false;
                }
                if(!_this.form.userPassword){
                    _this.$message.error('抱歉,请输入密码!');
                    return false;
                }
				// window.location.href="index.html?v="+Math.random();
                var json={
                    userName:_this.form.userName,
                    userPassword:_this.form.userPassword                 
                };
                $.ajax({
                    type: 'post',   //POST/PUT/DELETE/HEAD...
                    url:globalUrl+"/login/login",
                    // beforeSend: function(request) { request.setRequestHeader("Authentication",serviceToken);  },
                    data:JSON.stringify(json),
                    dataType: 'json',	//text/script/xml/json/jsonp
                    contentType:"application/json; charset=UTF-8",
                    success: function (data) {
                        console.log(data);
                        if(data.code===1){
                            _this.$message('登录成功');
                            localStorage.setItem("idgarage",data.data.idgarage);
                            localStorage.setItem("userId",data.data.userId);
                            window.location.href="index.html?v="+Math.random();
                        }else{
                            _this.$message.error(data.msg);
                        }
                    }
                });
            }
        },
        created: function () {

        }
    });
</script>
</body>
</html>